<template>
  <div class="div1">
    <div>
      <van-nav-bar
          left-text="返回"
          left-arrow
          @click-left="onClickLeft"
      />
    </div>
    <div class="dv">
    <div>
      <h2>探途信息填写</h2>
    </div>
    <div class="div2">
      <van-cell-group inset>
        <!-- 输入任意文本 -->
        <van-field v-model="user2.name" type="text" label="昵称" />
        <!-- 输入密码 -->
        <van-field v-model="user2.password" type="password" label="密码" />
        <!-- 输入密码 -->
        <van-field  v-model="user2.password1" type="password" label="密码确认" />
      </van-cell-group>


    </div>

    <div style="margin: 16px;">
      <van-button round block type="success" v-model="checked" :disabled="btn2" @click="registerCode()">
        注册
      </van-button>
    </div>
    </div>
    <div class="dv2">
      <van-checkbox v-model="check"  @click="clickbtn()" ><h5 @click="tz()">我已同意《探途用户协议》</h5></van-checkbox>
<!--      <van-checkbox v-model="checked"  @click="dianji()" checked-color="#ee0a24">我已同意《探途用户协议》</van-checkbox>-->
    </div>


  </div>

</template>

<script>
export default {
  name: "RegisterSucceedView",


  data() {

    return {
      btn2: true,
      user2: {//手机号验证码
        name: "",
        password: "",
        phone: ""
      },
      check:false,
    }
    // this.user2.phone=this.$route.phones;
    // console.log(this.user2)
      },
      created(){
      this.getParams()
      },
      methods: {
        onClickLeft() {
          history.back()
        },

        clickbtn(check){
          if(check=true){
            this.btn2=false;
          }else {
            this.btn2=true;
          }
        },

        registerCode() {
          console.log(this.user2);
          //验证码注册

          this.axios.post("api/user/register.do", this.user2).then((r) => {
            if (r.data.code == 200) {
              this.btn2 = true;
              this.$store.commit("setToken", r.data.data);
              //成功 跳转到首页
              this.$router.push("/login");
            } else {
              this.btn2=false;
              this.$toast("注册失败");
            }
          })
        },




        watch:{
          '$route': 'getParams'
        },
        getParams(){
          const routerParams = this.$route.query
         this.user2.phone=routerParams.phones
          this.user2.code=routerParams.codes
        },
        tz(){
          this.$router.push("/agree");
        }
      }



}

</script>

<style scoped>
.div1{
  height:670px ;
  background: url(https://ts1.cn.mm.bing.net/th/id/R-C.c386886de4e805ef85264c1dc9dca728?rik=%2bTCzu7hMyFHcEw&riu=http%3a%2f%2fwww.chuquwanwanba.com%2fuploads%2fimage2%2f20200803%2f1596415209889.gif&ehk=sbXAbOo3Be8HB82FZwsJCuxfSVyxsSS1%2fsboj3EU1M4%3d&risl=&pid=ImgRaw&r=0) no-repeat;
  background-size: cover;
  background-attachment: fixed;
}
.dv{
  opacity: 0.9;
  margin-top: 68px ;
}
.dv2{
  padding-left: 20px;
  margin-top: 1px ;
}


</style>